package com.gky.gkytemplate.common.enums;

import cn.hutool.core.util.ObjectUtil;

/**
 * 用户角色枚举类
 */
public enum UserRoleEnum {

    USER("用户","user"),
    ADMIN("管理员","admin"),
    BAN("被封号","ban");

    private final String desc;

    private final String value;

    UserRoleEnum(String desc, String value){
        this.desc = desc;
        this.value = value;
    }

    /**
     * 根据value返回枚举
     * @param value
     * @return
     */
    public static UserRoleEnum getEnumsByValue(String value){
        if (ObjectUtil.isEmpty(value)){
            return null;
        }
        for (UserRoleEnum anEnum : UserRoleEnum.values()){
            if (anEnum.value.equals(value)){
                return anEnum;
            }
        }
        return null;
    }


    public String getDesc() {
        return desc;
    }

    public String getValue() {
        return value;
    }
}
